package com.tansun.ruledata.data.dao;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;

@Service
public class RuleLogBackupDao {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	/**
	 * 代码解析异常的情况下,保存数据到规则日志备份表中
	 * 
	 * @param redisDataLogs
	 * @param redisDataDetailLogs
	 */
	public void saveLogToBackup(String ruleLog, List<String> redisDataDetailLogs) {
		StringBuffer sqlBuf = new StringBuffer();
		sqlBuf.append(
				"insert INTO rule_logsbackup (rule_logs,rule_log_details,issynchronism,create_date) values (?,?,?,?)");
		jdbcTemplate.update(sqlBuf.toString(), new Object[] {ruleLog, JSON.toJSONString(redisDataDetailLogs), "0", new Date() });
	}

}
